package com.originskyseed.platform.user.mapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.originskyseed.platform.user.model.TaskSelectSaleManVO;
import com.originskyseed.platform.user.model.UserInfo;

/**
 * 用户信息表Mapper类（OSI_USER_INFO）
 *
 * @author LiangMingHui
 */
public interface UserInfoMapper {

	/**
	 * 删除记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	// public int deleteByPrimaryKey(String id) throws Exception;

	/**
	 * 删除记录
	 *
	 * @param account
	 * @return
	 * @throws Exception
	 */
	public int deleteByAccount(String account) throws Exception;

	/**
	 * 查询记录
	 *
	 * @param account
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByAccount(@Param("account") String account) throws Exception;

	/**
	 * 查询记录
	 *
	 * @param type
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectByType(@Param("type") Integer type) throws Exception;

	/**
	 * 查询所有的记录
	 *
	 * @param account
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectAllByAccount(@Param("account") String account) throws Exception;

	/**
	 * 批量删除记录
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	// public int deleteByPrimaryKeys(List<String> ids) throws Exception;

	/**
	 * 批量删除记录根据账户
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	// public int deleteByAccounts(List<String> ids) throws Exception;

	/**
	 * 批量插入
	 *
	 * @param userInfoList
	 * @return
	 * @throws Exception
	 */
	public int insertBatchUser(@Param("userInfoList") List<UserInfo> userInfoList) throws Exception;

	/**
	 * 插入记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insert(UserInfo record) throws Exception;

	/**
	 * 插入记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insertSelective(UserInfo record) throws Exception;

	/**
	 * 更新记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKey(UserInfo record) throws Exception;

	/**
	 * 更新记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKeySelective(UserInfo record) throws Exception;


	/**
	 * 更新员工等级信息
	 * @param id
	 * @param levelId
	 * @return
	 * @throws Exception
	 */
	public int updateLevelIdByUserId(@Param("id") String id, @Param("levelId") String levelId, @Param("updateTime") Date updateTime) throws Exception;
	/**
	 * 查询记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByPrimaryKey(String id) throws Exception;

	/**
	 * 根据用户名称查询
	 *
	 * @param username
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByName(String username) throws Exception;

	/**
	 * 查询列表
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectList(UserInfo record) throws Exception;

	/**
	 * 查询导出列表
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectExportExcelList(UserInfo record) throws Exception;

	/**
	 * 分页查询列表
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectListByPage(Map<String, Object> params) throws Exception;

	/**
	 * 分页查询列表
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectListRelRoleByPage(Map<String, Object> params) throws Exception;

	/**
	 * 选择人员信息
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectMaintainListByPage(Map<String, Object> params) throws Exception;

	/**
	 * 选择业务员信息公会、全平台
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<TaskSelectSaleManVO> selectSaleInfoListByPage(Map<String, Object> params) throws Exception;

	/**
	 * 选择主播信息公会、全平台
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<TaskSelectSaleManVO> selectMaintainAnchorListByPage(Map<String, Object> params) throws Exception;


	/**
	 * 推广任务选择主播
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<TaskSelectSaleManVO> selectPromotionTaskAnchorListByPage(Map<String, Object> params) throws Exception;

	/**
	 * 根据公会Id分页查询列表
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectListBytradeunionIdPage(Map<String, Object> params) throws Exception;

	/**
	 * 逻辑删除用户
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int deleteLogicallyByPrimaryKeys(List<String> ids) throws Exception;

	/**
	 * 逻辑更新（恢复）用户
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int updateLogicallyByPrimaryKeys(List<String> ids) throws Exception;

	/**
	 * 启用或禁用用户
	 *
	 * @param ids
	 * @param status
	 * @return
	 * @throws Exception
	 */
	public int updateStatus(@Param("ids") List<String> ids, @Param("status") Integer status) throws Exception;

	/**
	 * 签约或未签约
	 *
	 * @param ids
	 * @param isEconomicContract
	 * @return
	 * @throws Exception
	 */
	public int updateIsEconomic(@Param("ids") List<String> ids, @Param("isEconomicContract") Integer isEconomicContract) throws Exception;

	/**
	 * 更新APP_ACCOUNT
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int updateAppAccount(@Param("ids") List<String> ids, @Param("appAccount") String appAccount) throws Exception;

	/**
	 * 账号是否存在
	 *
	 * @param account
	 * @return
	 * @throws Exception
	 */
	public boolean existAccount(String account) throws Exception;

	/**
	 * 查询用户是否存在
	 *
	 * @param account
	 * @return
	 */
	UserInfo existUserInfoAccount(String account);

	/**
	 * 修改账号密码
	 *
	 * @param account
	 * @param password
	 * @return
	 * @throws Exception
	 */
	public int updateUserInfoPassword(@Param("account") String account, @Param("password") String password) throws Exception;

	/**
	 * 手机号是否存在
	 *
	 * @param mobileNumber
	 * @return
	 * @throws Exception
	 */
	public boolean existMobileNumber(@Param("mobileNumber") String mobileNumber) throws Exception;

	/**
	 * 根据手机号和密码获取用户信息
	 *
	 * @param mobileNumber
	 * @param password
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByPhoneAndPassword(@Param("mobileNumber") String mobileNumber, @Param("password") String password) throws Exception;

	/**
	 * 根据手机号获取用户信息
	 *
	 * @param mobileNumber
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectMobileNumber(@Param("mobileNumber") String mobileNumber) throws Exception;

	/**
	 * 判断账户是否重复
	 *
	 * @param userInfo
	 * @return
	 * @throws Exception
	 */
	public Boolean accountExist(UserInfo userInfo) throws Exception;

	/**
	 * 判断名称是否重复
	 *
	 * @param userInfo
	 * @return
	 * @throws Exception
	 */
	public Boolean nameExist(UserInfo userInfo) throws Exception;

	/**
	 * 根据账号修改状态
	 *
	 * @param userInfo
	 * @return
	 * @throws Exception
	 */
	public int updateByAccount(UserInfo userInfo) throws Exception;

	/**
	 * 查询记录
	 *
	 * @param account
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByAccountOne(String account) throws Exception;

	/**
	 * 根据会员ID删除用户信息
	 *
	 * @param memberId
	 * @return
	 */
	int deleteByMemberId(String memberId) throws Exception;

	/**
	 * 查询账号数量，根据手机号码查询
	 *
	 * @param mobileNumber
	 * @return
	 * @throws Exception
	 */
	int selectCountByMobileNumber(@Param("mobileNumber") String mobileNumber) throws Exception;

	/**
	 * 根据openId获取用户信息
	 *
	 * @param openId
	 * @return
	 * @throws Exception
	 */
	List<UserInfo> selectUserInfoByOpenId(String openId) throws Exception;

	/**
	 * 删除用户绑定的opId
	 *
	 * @param userInfo
	 * @return
	 * @throws Exception
	 */
	int deleteUserOpId(UserInfo userInfo) throws Exception;

	/**
	 * 根据用户ID查询母账号 传入母账号ID则返回自己
	 *
	 * @param userId
	 * @return
	 */
	UserInfo selectBySonUserId(@Param("userId") String userId);

	/**
	 * 根据手机号查询用户信息
	 *
	 * @param phone
	 * @return
	 * @throws Exception
	 */
	UserInfo selectByPhoneNum(@Param("phone") String phone) throws Exception;

	/**
	 * 查询不对账的账号
	 *
	 * @return
	 * @throws Exception
	 */
	List<String> selectNotBillAuditAccount() throws Exception;

	/**
	 * 查询不统计订单的账号
	 *
	 * @return
	 * @throws Exception
	 */
	List<String> selectNotStatisticsAccount() throws Exception;

	/**
	 * 更具手机号查询用户信息，并且可指定source
	 *
	 * @param phone
	 * @return
	 */
	UserInfo selectByPhoneNumAndSource(@Param("phone") String phone, @Param("source") String source) throws Exception;

	/**
	 * 查询用户信息列表
	 *
	 * @param param
	 * @return
	 * @throws Exception
	 */
	List<UserInfo> selectUserMemberListByPage(Map<String, Object> param) throws Exception;

	/**
	 * 根据角色分页查询用户列表
	 *
	 * @param param
	 * @return
	 * @throws Exception
	 */
	List<UserInfo> selectUserRoleListByPage(Map<String, Object> param) throws Exception;

	/**
	 * 查询满减会员列表
	 *
	 * @param param
	 * @return
	 * @throws Exception
	 */
	List<UserInfo> selectFullSubtractMemberListByPage(Map<String, Object> param) throws Exception;

	/**
	 * 根据子账号查询母账号
	 *
	 * @param account
	 * @return
	 */
	public UserInfo selectUserBySonAccount(@Param("account") String account) throws Exception;

	/**
	 * 根据OA组织编码查询母账户
	 *
	 * @param oaOrgCode
	 * @return
	 */
	public UserInfo selectByOrgCode(@Param("oaOrgCode") String oaOrgCode, @Param("mallCode") String mallCode) throws Exception;

	/**
	 * 查询OA账号
	 *
	 * @return
	 */
	public List<UserInfo> selectOaAccount() throws Exception;

	/**
	 * 清除其他账户的openId
	 *
	 * @param openId
	 * @param account
	 * @return
	 */
	public int clearOtherUserOpenId(@Param("openId") String openId, @Param("account") String account);

	/**
	 * 查询用户名字的最大值
	 *
	 * @param account
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectMaxAccount(@Param("account") String account) throws Exception;

	/**
	 * 更新记录根据账号（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByAccountSelective(UserInfo record) throws Exception;

	/**
	 * 根据账号和密码获取用户信息
	 *
	 * @param account
	 * @param password
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByAccountAndPassword(@Param("account") String account, @Param("password") String password) throws Exception;

	/**
	 * 查询员工编号
	 *
	 * @return
	 * @throws Exception
	 */
	public String selectUserNum() throws Exception;

	/**
	 * 查询最大的优先级
	 *
	 * @return
	 * @throws Exception
	 */
	public Integer selectPrority() throws Exception;

	/**
	 * 根据优先级查询员工
	 *
	 * @param prority
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectUserByPrority(Integer prority) throws Exception;

	/**
	 * 根据部门id查询员工数量
	 *
	 * @param deptId
	 * @return
	 * @throws Exception
	 */
	public int selectUserNumByDeptId(String deptId) throws Exception;

	/**
	 * 根据部门id查询员工数量,排除异常状态的
	 *
	 * @param deptId
	 * @return
	 * @throws Exception
	 */
	public int selectUserNumByStatusDeptId(String deptId) throws Exception;

	/**
	 * 根据部门id集合查询员工数量,排除异常状态的
	 *
	 * @param deptIds
	 * @return
	 * @throws Exception
	 */
	public int selectUserNumByStatusDeptIds(@Param("list") List<String> deptIds) throws Exception;

	/**
	 * 查询第三方主键是否存在
	 *
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public List<String> selectRepeatOtherId(Map<String, Object> map) throws Exception;

	/**
	 * 根据部门id查询用户id
	 *
	 * @param deptId
	 * @return
	 * @throws Exception
	 */
	public List<String> selectUserIdsByDeptId(@Param("deptId") String deptId) throws Exception;

	/**
	 * 根据用户id查询用户id第三方主键
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public String selectOtherAccountById(@Param("id") String id) throws Exception;

	/**
	 * 根据第三方主键查询用户
	 *
	 * @param otherAccount
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByOtherAccount(@Param("otherAccount") String otherAccount) throws Exception;

	/**
	 * 根据部门查询业务员id
	 *
	 * @param list
	 * @return
	 * @throws Exception
	 */
	public List<String> selectSalesmanIdsByDeptIds(@Param("list") List<String> list) throws Exception;

	/**
	 * 根据部门查询第三方账号
	 *
	 * @param type  1 内容 2 推广
	 * @param list
	 * @return
	 * @throws Exception
	 */
	public List<String> selectOtherAccountByDeptIds(@Param("list") List<String> list,@Param("type") Integer type) throws Exception;


	/**
	 * 根据部门查询青芒主播id
	 *
	 * @param list
	 * @return
	 * @throws Exception
	 */
	public List<String> selectAnchorOtherIdsByDeptIds(@Param("list") List<String> list) throws Exception;

	/**
	 * 查询新增的主播数量
	 *
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public Integer selectAnchorNumberByTime(Map<String, Object> map) throws Exception;

	/**
	 * 根据部门ID查询用户
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<String> selectUserIdsByDeptIds(@Param("list") List<String> deptIdList) throws Exception;

	/**
	 * 根据部门ID查询用户
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<String> selectAccountByDeptIds(@Param("list") List<String> deptIdList) throws Exception;

	/**
	 * 根据部门ID查询主播id
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<String> selectAnchorIdsUserIdsByDeptIds(@Param("deptIdList") List<String> deptIdList) throws Exception;

	/**
	 * 根据部门ID查询用户表中主播的第三方主键
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<String> selectAnchorOtherAccountsByDeptIds(@Param("deptIdList") List<String> deptIdList) throws Exception;

	/**
	 * 培训任务查询新员工
	 *
	 * @return
	 */
	public List<UserInfo> taskSelectNewUserList(Map<String, Object> map) throws Exception;

	/**
	 * 通过部门Id 类型查询用户
	 *
	 * @return
	 */
	public UserInfo selectUserInfoByDeptIdAndType(Map<String, Object> map) throws Exception;

	/**
	 * 根据部门ID查询业务员用户id
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<String> selectSalesmanUserIdsByDeptIds(@Param("list") List<String> deptIdList) throws Exception;

	/**
	 * 根据部门ID查询业务员用户id
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectSalesUserInfoByDeptIds(@Param("deptIdList") List<String> deptIdList) throws Exception;

	/**
	 * 根据部门ID查询主播用户id
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<String> selectAnchorIdsByDeptIds(@Param("deptIdList") List<String> deptIdList) throws Exception;

	/**
	 * 根据部门ID查询主播信息
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectAnchorInfoByDeptIds(@Param("deptIdList") List<String> deptIdList) throws Exception;

	/**
	 * 查询所有用户信息
	 *
	 * @param deptIdList
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectUserInfoByDeptIds(@Param("deptIdList") List<String> deptIdList) throws Exception;

	/**
	 * 根据部门查询成员
	 *
	 * @param deptId
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectUserByDeptId(@Param("deptId") String deptId) throws Exception;

	/**
	 * 邀请码是否存在
	 *
	 * @param account
	 * @return
	 * @throws Exception
	 */
	public boolean existOwnInvitationCode(String account) throws Exception;

	/**
	 * 根据根据当前时间查询新用户
	 *
	 * @param nowTime
	 * @return
	 * @throws Exception
	 */
	public List<UserInfo> selectUserByNowTime(@Param("nowTime") String nowTime) throws Exception;

	/**
	 * 根据邀请码查询员工
	 *
	 * @param ownInvitationCode
	 * @return
	 * @throws Exception
	 */
	public UserInfo selectByOwnInvitationCode(@Param("ownInvitationCode") String ownInvitationCode) throws Exception;


	/**
	 * 查询是否有业务员和主播
	 *
	 * @param deptId
	 * @return
	 * @throws Exception
	 */
	public Integer selectIsHaveChildren(@Param("deptId") String deptId) throws Exception;
}
